<html>
 <head></head>
 <body>
  <div class="wrap">
   <div class="container">
    <div class="row">
     <div id="secondary" class="col-md-2">
      <nav class="list-group mt30">
       <a href="{:U('home/User/userinfo')}" class="list-group-item">个人资料</a>
       <a target="_blank" href="/u/huangzhenjiangvip/profile" class="list-group-item">个人档案 <i style="line-height: 20px;font-size: 12px;color: #999;" class="pull-right fa fa-external-link-square"></i></a>
       <a href="{:U('home/User/useremail')}" class="list-group-item">Email 地址</a>
       <a href="javascript:void(0)" class="list-group-item active">密码修改</a>
       <a href="/user/settings?tab=oauth" class="list-group-item">第三方账号</a>
      </nav>
      <nav class="list-group mt30">
       <a href="/user/settings?tab=notify" class="list-group-item">通知和私信</a>
       <a href="/user/settings?tab=card" class="list-group-item">个性名片</a>
       <a href="/user/settings?tab=block" class="list-group-item">屏蔽名单</a>
       <a href="/user/settings?tab=lab" class="list-group-item">实验室功能</a>
      </nav>
     </div>
     <!-- end #secondary -->
     <div id="main" class="settings col-md-10 form-horizontal">
      <form id="setting" action="{:U('home/user/editpassword')}" method="post">
       <h2 class="h3 mt30 post-title">密码修改</h2>
       <div class="form-group mt30">
        <label for="oldpassword" id="oldpassword"  class="required control-label col-sm-2" >当前密码</label>
        <div class="col-sm-8">
         <input name="password" placeholder="输入当前密码" id="oldpassword" type="password" class="form-control theinputs" required="" status=""/>
         <span class="reforms" style="padding-left:5px;"></span>
         <!-- <p class="help-block mb0">不知道密码？你可以 <a href="/user/forgot">重置密码</a> -->
         </p>
        </div>
       </div>
       <div class="form-group">
        <label for="newpassword"   class="required control-label col-sm-2" >新密码</label>
        <div class="col-sm-8">
         <input name="newPassword" placeholder="请输入新密码" id="newpassword" type="password" class="form-control theinputs" required="" status="" />
         <span class="reforms" style="padding-left:5px;"></span>
        </div>
       </div>
       <div class="form-group">
        <label for="confirmPassword"  class="required control-label col-sm-2" status="">确认新密码</label>
        <div class="col-sm-8">
         <input name="confirmPassword" id="confirmpassword" placeholder="重复上面的新密码" id="confirmPassword" type="password" class="form-control theinputs" required="" status="" />
         <span class="reforms" style="padding-left:5px;"></span>
        </div>
       </div>
       <div class="form-action row">
        <div class="col-sm-10 col-sm-offset-2">
         <button class="btn btn-xl btn-primary password-sub" id="subtn" disabled="disabled">提交</button>
        </div>
       </div>
      </form>
     </div>
    </div>
   </div>
  </div>
   <script type="text/javascript" src="__PUBLIC__/js/jquery-1.7.2.js"></script>
   <script type="text/javascript">
      $(document).ready(function() {
         //当前对象是新密码的时候 清空确认密码的提示
         $('#newpassword').focus(function(event) {
            $('#confirmpassword').val('');
            $('#subtn').attr('disabled', 'disabled');
            $(this).siblings('.reforms').html("");
            $('#confirmpassword').siblings('.reforms').html("");
         });

        $('#oldpassword,#newpassword,#confirmpassword').blur(function(event) {
          var thisobj = $(this);
          var thisvalue = $(this).val();
          var thisname = $(this).attr('id');

          if(thisvalue == ''){
            thisobj.siblings('.reforms').html("");
            return false;
          }
          //当前对象是确认密码的时候
          if(thisname == 'confirmpassword' ){
            if($('#newpassword').attr('status') == ''){
              thisobj.siblings('.reforms').html("<span style='color:red'>请先规范填写新密码</span>");
              return false;
            }
          }
          $.ajax({
            url: '{:U("home/user/GetThisData")}',
            type: 'POST',
            dataType: 'json',
            data: thisname + "=" + thisvalue,
            success:function(data){
              if(data.error == 0){
                
                thisobj.siblings('.reforms').html("<span style='color:blue'>"+data.content+"</span>");
                thisobj.attr('status', 'ok');

                var checkobj = $('.theinputs');
                var c = 1;
                $.each(checkobj, function(index, val) {

                  if($(this).attr('status') == ''){
                    c = 0; 
                  }
                });
                if(c){
                  $('#subtn').removeAttr('disabled');
                }

              }else{
                 thisobj.siblings('.reforms').html("<span style='color:red'>"+data.content+"</span>");
                 thisobj.attr('status', '');
                 $('#subtn').attr('disabled', 'disabled');
              }
            },
            error:function(){
              alert('通讯错误');
            },
          })

        });
      });
   </script>
 </body>
</html>